import processing.core.*;


public class Nappi {
	  private int x;
	  private int y;
	  private String teksti;
	  PApplet pa;
	  
	  
	  public Nappi(int x, int y, String teksti, PApplet parent) {
	    this.x = x;
	    this.y = y;
	    this.teksti = teksti;
	    pa = parent;
	  }
	  
	  //Piirt�� napin
	  public void piirra() {
		pa.stroke(0);
		pa.strokeWeight(5);
		pa.line(this.x,this.y, this.x+200,this.y);
		pa.line(this.x,this.y, this.x,this.y+120);
		pa.line(this.x,this.y+120, this.x+200,this.y+120);
		pa.line(this.x+200,this.y, this.x+200,this.y+120);
	    this.asetaTeksti(this.teksti);
	  }
	  
	  //Asettaa nappiin tekstin
	  public void asetaTeksti(String teksti) { 
	    pa.fill(0);
	    this.teksti = teksti;
	    
	    pa.textSize(28);

	    
	    int tekstix = this.x + 100;
	    int tekstiy = this.y+ 20;
	    
	    pa.textAlign(PApplet.CENTER);
	    pa.textSize(12);
	    pa.text(this.teksti, tekstix, tekstiy);
	  }
	  
	}
